// vim: foldmethod=marker : foldmarker=<<<,>>>
/*
 File: datum.h
 Product: <product>
 Creating date: 22/06/2006 10:01
 Remark: 
*/
#pragma once

#include "lite/lite.h"

typedef struct _spool_datum_t_ {
 union {
  v_p raw;
  c_p str;
  w_p wstr;
  i1_p data;
  };
 i_t size;
 } spool_datum_t;
typedef spool_datum_t * spool_datum_p;
typedef spool_datum_p * spool_datum_pp;

#define STR__spool_datum(datum) (datum)->str,(datum)->size
#define RAW__spool_datum(datum) (datum)->raw,(datum)->size
#define DATA__spool_datum(datum) (datum)->data,(datum)->size

#define STRREF__spool_datum(datum) &(datum)->str,&(datum)->size
#define RAWREF__spool_datum(datum) &(datum)->raw,&(datum)->size
#define DATAREF__spool_datum(datum) &(datum)->data,&(datum)->size

inline_q v_t zero__spool_datum(spool_datum_p _this)
 { _this->raw=NULL; _this->size=0; }

inline_q v_t putRaw__spool_datum(spool_datum_p _this, R_p(raw)) 
 { _this->raw=raw; _this->size=rawSize; };

inline_q v_t putString__spool_datum(spool_datum_p _this, S_p(str)) 
 { _this->str=str; _this->size= strSize==-1?slen(str):strSize; };

inline_q i_t isEqualString__spool_datum(
   spool_datum_p _this
 , c_p str
 , i_t strSize
 ) {
 if (strSize==-1) strSize=slen(str);
 return _this->size==strSize && mcmp(_this->str,str,strSize)==0;
 };

inline_q i_t isEqual__spool_datum(spool_datum_p _this, spool_datum_p other) {
 return _this->size==other->size && mcmp(_this->raw,other->raw,_this->size)==0;
 };

